package it.tic.sbibm.bl;

import java.io.Serializable;

public class FunctionResultBean implements Serializable {
	private static final long serialVersionUID = 769112416876613966L;

	public static final String RESULT_OK = "OK";
	public static final String RESULT_ERROR = "ERROR";

	private String resultCode;
	private String message;
	private Object furtherObjects;
	
	public FunctionResultBean(String resultCode, Object furtherObjects) {
		this.resultCode = resultCode;
		this.furtherObjects = furtherObjects;
	}
	
	public FunctionResultBean(String resultCode, String message) {
		this.resultCode = resultCode;
		this.message = message;
		this.furtherObjects = null;
	}
	
	public FunctionResultBean(String resultCode) {
		this(resultCode, "");
	}
	
	public boolean isOk() {
		if (resultCode != null && resultCode.equals(RESULT_OK)) return true;
		else return false;
	}

	public boolean isError() {
		if (resultCode != null && resultCode.equals(RESULT_ERROR)) return true;
		else return false;
	}

	public Object getFurtherObjects() {
		return furtherObjects;
	}

	public void setFurtherObjects(Object furtherObjects) {
		this.furtherObjects = furtherObjects;
	}

	public String getResultCode() {
		return resultCode;
	}

	public void setResultCode(String resultCode) {
		this.resultCode = resultCode;
	}

	public String getMessage() {
		return message;
	}
	
	public void setMessage(String message) {
		this.message = message;
	}

	public static FunctionResultBean getResultErrorInstance() {
		return new FunctionResultBean(RESULT_ERROR);
	}
	
	public static FunctionResultBean getResultErrorInstance(String message) {
		return new FunctionResultBean(RESULT_ERROR, message);
	}
		
	public static FunctionResultBean getResultOkInstance() {
		return new FunctionResultBean(RESULT_OK);
	}
	
	public static FunctionResultBean getResultOkInstance(Object furtherObjects) {
		return new FunctionResultBean(RESULT_OK, furtherObjects);
	}
}
